/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package WekaModels;

import grex.Data.ArffTableModel;
import grex.ErrorManager;
import grex.Prediction;
import grex.PredictionContainer;
import weka.classifiers.functions.LinearRegression;
import weka.classifiers.functions.PaceRegression;
import weka.classifiers.rules.ZeroR;
import weka.core.Instance;
import weka.core.Instances;

/**
 *
 * @author RIK
 */
public class GrexPaceRegression extends WekaPredictiveModel{
    private PaceRegression paceRegresion;
    public GrexPaceRegression(ArffTableModel data){
        super(data,new PaceRegression());
        this.paceRegresion = (PaceRegression) model;        
    }

    public double getNrOfNodes() {
        return 1;
    }
    
        @Override
        public void execute(PredictionContainer pc) {
        for (Prediction p : pc.values()) {

            try {
                Instance instance = wekaArffTableModel.getInstance(p.getInstance(),wekaTrain);//wekaTrain is just used to set the Dataset in the instance
                double prediction;
                prediction = Math.max(model.classifyInstance(instance),0);
                
                p.setProbs(model.distributionForInstance(instance));
                p.setPrediction(prediction);
             
            } catch (Exception ex) {
                ErrorManager.getInstance().reportError(ex);
            }

        }
    }

    public String getName() {
        return "PaceR";
    }
    
}
